//
//  SettingViewController.swift
//  FirstSwiftProduct
//
//  Created by 知合金服-Mini on 2017/12/8.
//  Copyright © 2017年 范泽华. All rights reserved.
//

import UIKit

class SettingViewController: BasePushViewController ,UITableViewDelegate,UITableViewDataSource{
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let headView = UIView.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 10))
        return headView
    }
    func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat {
        return 10
    }
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let headView = UIView.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 10))
        return headView
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return titleArr.count
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return titleArr[section].count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell.init(style: .value1, reuseIdentifier: "cellId")
        cell.textLabel?.text = titleArr[indexPath.section][indexPath.row]
        cell.accessoryType = .disclosureIndicator
        let logOutLabel = UILabel.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 44))
        logOutLabel.textAlignment = .center
        cell.contentView.addSubview(logOutLabel)
        
        cell.selectionStyle = .none
        if indexPath.section == titleArr.count - 1  {
            cell.textLabel?.text = ""
            logOutLabel.text = "退出登录"
            cell.accessoryType = .none
            cell.textLabel?.center = cell.contentView.center
            logOutLabel.isHidden = false
        }else{
            logOutLabel.isHidden = true
        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print(indexPath.row)
    }
    
    let titleArr = [["账号与安全"],["新消息通知","隐私","通用"],["帮助与反馈","关于爸爸"],["插件"],["退出登录"]]
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        self.titleLabel.text = "设置"
        
        let tableView = UITableView.init(frame: CGRect(x: 0, y: CGFloat(kStatus_Navigation_height), width: SCREEN_WIDTH, height: SCRENN_HEIGHT -  CGFloat(kStatus_Navigation_height)), style: .grouped)
        tableView.delegate = self
        tableView.dataSource = self
        
        view.addSubview(tableView)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
